﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ComplexEventProcessing;
using Microsoft.ComplexEventProcessing.Adapters;
using IntroHost.EventType;

namespace WcfInputAdapter
{
    public class WcfInputAdapterFactory : ITypedInputAdapterFactory<WcfInputAdapterConfing>, ITypedDeclareAdvanceTimeProperties<WcfInputAdapterConfing>
    {
        internal static readonly string ADAPTER_NAME = "WcfInput";

        public InputAdapterBase Create<TPayload>(WcfInputAdapterConfing configInfo, EventShape eventShape)
        {
            InputAdapterBase ret = default(InputAdapterBase);

            switch (eventShape)
            {
                case EventShape.Point:
                    //ret = new WcfInputPointAdapter<TPayload>(configInfo);
                    ret = new WcfInputPointAdapter(configInfo);
                    break;
                default:
                    throw new ApplicationException("Only Point Adapters are Available");
            }
            return ret;
        }

        public void Dispose()
        {

        }

        public AdapterAdvanceTimeSettings DeclareAdvanceTimeProperties<TPayload>(WcfInputAdapterConfing configInfom, EventShape eventShape)
        {
            var timeGenSettings = new AdvanceTimeGenerationSettings(configInfom.CtiFrequency, TimeSpan.FromTicks(-1), true);
            return new AdapterAdvanceTimeSettings(timeGenSettings, AdvanceTimePolicy.Adjust);
        }
    }
}
